public class Main {
    public static void main(String[] args) {
        printFigure(17, 15);
    }

    public static void printFigure(int h, int w) {
        boolean check = true;
        int t = 0, t2 = 0, tt = 0;
        System.out.print(" ");
        for (int i = 0; i < w - 2; i++)
            System.out.print("-");
        System.out.println();
        for (int i = 1; i < h - 1; i++) {
            if (t == 0) {
                tt++;
                t = tt;
            }
            System.out.print("|");
            for (int j = 0; j < w - 2; j++) {
                if (check && t > 0) {
                    System.out.print("!");
                    t--;
                    if (t < 1)
                        check = false;
                } else if (!check && t2 > 0) {
                    System.out.print(" ");
                    t2--;
                    if (t2 < 1)
                        check = true;
                }
                if (t2 == 0)
                    t2 = w - 2;
            }
            System.out.println("|");
        }
        System.out.print(" ");
        for (int i = 0; i < w - 2; i++)
            System.out.print("-");
        System.out.println();
    }
}
